<template>
  <div id="echarts5"></div>
</template>

<script>
import * as echarts from 'echarts';

export default {
  props: ['data'],
  data() {
    return {}
  },
  mounted() {
    this.initEcharts()
  },
  methods: {
    initEcharts(data, labels) {
      data,labels
      const chartDom = document.getElementById('echarts5')
      const myChart = echarts.init(chartDom)
      let option

      option = {
        grid:{
          bottom:'5%'
        },
        xAxis: {
          type: 'category',
          data: ['03/08', '03/09', '03/10', '03/11', '03/12', '03/13', '03/14']
        },
        yAxis: {
          type: 'value'
        },

        series: [
          {
            data: [820, 932, 901, 934, 1290, 1330, 1320],
            type: 'line',
            smooth: true
          }
        ]
      };

      option && myChart.setOption(option);
    }
  },
  watch: {
    data({data, labels}) {
      this.initEcharts(data, labels)
    }
  }
}
</script>

<style scoped>
#echarts5 {
  width: 100%;
  height: 500px;
}
</style>
